package utils

import (
	"fmt"
	"github.com/jordan-wright/email"
	"go-admin/define"
	"net/smtp"
)

// SendEmail 发送邮箱
func SendEmail(toEmail string, subject string, content string) {
	e := email.NewEmail()
	// 设置发送方的邮箱
	e.From = define.EmailFrom
	// 设置接收方的邮箱
	e.To = []string{toEmail}
	// 设置标题
	e.Subject = subject
	// 设置邮箱发送的内容
	e.Text = []byte(content)
	// 设置服务器相关配置
	emailAddr := define.EmailHost + ":" + define.EmailPort
	err := e.Send(emailAddr, smtp.PlainAuth("", define.EmailFrom, define.EmailPassword, define.EmailHost))
	if err != nil {
		fmt.Println(err)
	}

}
